from typing import List

R = 0

class Solution:
    def plusOne(self, digits: List[int]) -> List[int]:
        global R
        if len(digits) > 0:
            last = digits.pop() + 1
            R += 1
            if last == 10:
                self.plusOne(digits)
            else:
                digits.append(last)
                return R, digits
        else:
            return R, digits


if __name__ == '__main__':
    nums = [9]

    solution = Solution()

    print(solution.plusOne(nums))
